#!/bin/bash

if [ ${DIB_DEBUG_TRACE:-1} -gt 1 ]; then
    set -x
fi
set -eu
set -o pipefail

sudo mkdir -p $TMP_MOUNT_PATH/usr/share/pkg-map/

eval declare -A image_elements=($(get_image_element_array))

for i in "${!image_elements[@]}"; do
    element=$i
    element_dir=${image_elements[$i]}

    pkg_map="${element_dir}/pkg-map"
    if [ -f "${pkg_map}" ]; then
        echo "Copying pkg-map for ${element}"
        sudo cp "${pkg_map}" "$TMP_MOUNT_PATH/usr/share/pkg-map/$element"
    fi
done
